]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Set a strut to prevent windows under the panel
authorOwen Taylor <otaylor@src.gnome.org>
Wed, 19 Nov 2008 23:04:53 +0000 (23:04 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 19 Nov 2008 23:04:53 +0000 (23:04 +0000)
Set a strut (a reserved region) at the top of the screen so that
windows don't get positioned under the panel. Do this on all
workspaces and redo it when the number of workspaces changes.
http://bugzilla.gnome.org/show_bug.cgi?id=561297

svn path=/trunk/; revision=63

js/ui/panel.js

index 63f6c2d5ceb7ea0a94ec60ec8a9333547e67902d..358503e97fa7c4c305003d275e5c79f4866223b8 100644 (file)
@@ -2,11 +2,12 @@
 
 const Mainloop = imports.mainloop;
 
-const Shell = imports.gi.Shell;
 const Clutter = imports.gi.Clutter;
+const Meta = imports.gi.Meta;
+const Shell = imports.gi.Shell;
 const Tidy = imports.gi.Tidy;
-const Button = imports.ui.button;
 
+const Button = imports.ui.button;
 const Main = imports.ui.main;
 
 const PANEL_HEIGHT = 32;
@@ -86,12 +87,42 @@ Panel.prototype = {
                return true;
             });
 
+       this._setStruts();
+       global.screen.connect('notify::n-workspaces',
+           function() {
+               me._setStruts();
+           });
+
        global.stage.add_actor(this._group);
 
        this._updateClock();
        this._startClock();
     },
 
+    // Struts determine the area along each side of the screen that is reserved
+    // and not available to applications
+    _setStruts: function() {
+       let global = Shell.global_get();
+
+       let struts = [
+            new Meta.Strut({
+               rect: {
+                   x: 0,
+                   y: 0,
+                   width: global.screen_width,
+                   height: PANEL_HEIGHT
+               },
+               side: Meta.Direction.TOP
+           })
+       ];
+
+       let screen = global.screen;
+       for (let i = 0; i < screen.n_workspaces; i++) {
+           let workspace = screen.get_workspace_by_index(i);
+           workspace.set_builtin_struts(struts);
+       }
+    },
+
     _startClock: function() {
        let me = this;
         // TODO: this makes the clock updated every 60 seconds, but not necessarily on the minute, so it is inaccurate